package studio.wetrack.dinner.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import studio.wetrack.dinner.db.repo.TableRepo;
import studio.wetrack.dinner.domain.Table;
import studio.wetrack.dinner.service.TableSupplier;

import java.util.List;

/**
 * Created by zhanghong on 2017/8/12.
 */
@Service
public class TableServiceImpl implements TableSupplier {
    @Autowired
    TableRepo tableRepo;

    @Override
    public Table getTable(int count) {
        List<Table> tables = tableRepo.findByCapacityGreaterThanEqual(count);
        if(tables.size() == 0) return null;
        return tables.get(0);
    }
}
